<?php
/**
 * autoload.php
 * 自动加载器
 * 
 * @author  王中艺 <wangzy_smile@qq.com>
 * @date    2019-04-12 11:16:41
 */

# 自动加载注册
spl_autoload_register(function ($className) {
    $paths = explode('\\', $className);
    foreach($paths as $key => &$val){
        if ($key != count($paths) - 1) {
            $val = lcfirst($val); 
        }   
    }   
    
    $file = dirname(__FILE__) . '/' . implode('/', $paths) . '.php';
    if (!file_exists($file)) {
        throw new Exception('Class is not fount!');
    } else {
        require_once($file);
    }   
});

# 引入composer
require_once './vendor/autoload.php';

# 初始化配置
SmileYi\Utils\Config::set([
    'log' => [
        'dir' => dirname(__FILE__) . '/../extra/log/',
    ],
    'common' => [
        'salt' => '4ckNt8GrgvqXYg1u',
    ],
    'base64' => [
        // 编码表
        // 'map' => 'OBrsYZabgQRSTUtu3JnoPDChijklWApqKLM6Evw7Ncde45mxGHIfXyz012FV89+/',
        'map' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
    ],
    'upload' => [
        'dir' => dirname(__FILE__) . '/../extra/upload/',
        'exts' => ['jpg', 'png', 'jpeg'], // 不限制: ['*']
        'size' => 1024 * 1024 * 2,
    ],
    'app' => require_once('config.php')
]);